<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
    <head>
		<%@ include file="/WEB-INF/views/include/common.jsp" %>
		<meta name="AUTHOR" content="QroTech Inc." />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
		<meta http-equiv="PRAGMA" content="NO-CACHE">
		<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<title>큐로넷::위치관제시스템</title>
		
		<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
		<link rel="stylesheet" href="${cssUrl}/header-1.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/fancy_table.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/menu.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/table.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/button.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/secondmenu.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/body.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/Qronet_display_sub4.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/search-box.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/m-340.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/groupManage_popup_box.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/zipcode-popup.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/blue-popup-box.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/m-400.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/m-541.css" type="text/css" />
		
		<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
		<script src="${jsUrl}/pagenation.js"></script>
		<script src="${jsUrl}/windowSize.js"></script>
		<script src="${jsUrl}/m-541.js"></script>
		
    </head>
    <body>
    	<div id="overlay" class="overlay" >
    	</div><!-- overlay end -->
    	<div class="headerContent">
	
		<div class="pageHeader">
			<%@ include file="/WEB-INF/views/include/logoLink.jsp" %>
			<div id="pageNav">
				<ul>
					<%@ include file="/WEB-INF/views/include/mainNaviStyle2.jsp" %>
				</ul>
			</div>
			<div id="pageNavRight">
				<%@ include file="/WEB-INF/views/include/titleLink.jsp" %>
			</div>
		</div>
			<div class="header_line"></div>
		</div><!--header end-->	
		<div class="secondMenu" >
			<div id="menu">
				<%@ include file="/WEB-INF/views/include/m500innerNavi.jsp" %>
			</div>
		</div><!-- second menu end -->
		
		<div class="mainContent">	
			<div class="searchInfo">
					<ul>
						<li class= "locationInfo"><span>고객사관리</span></li>
						<li class="float-right">
			        				<ul class="search-autocomplete-box">
			        					
			        					<li>
			        						<select name="searchType" id="searchType">
						        				<option value="1">회사명</option>
						        				<option value="2">회사코드</option>
						        				<option value="3">사업자번호</option>
						        			</select>
			        					<li>
			        						<div class="autocomplete">
						        				<input type="text" style="width:150px;" name="searchName" id="searchName" onKeyup="getSearchName(this.value);" autocomplete="off">
													 	
				        					</div>
			        					</li>
			        					<li style="margin-right:20px;"><a onClick="getSearch()" class="button1" style="padding:2px 15px;">조회</a></li>
			        				</ul>
			        			</li>
					</ul>
					
			</div><!-- searchInfo end -->	
	        <div class="m510 m541">
	        
    				<div class="table_wrapper">	
    					<div class="m510-info-text m540-info-text m541-info-text">
			        		<ul>
			        			<li class="service-category">
			        				<ul >
						        		<li>
						        			회사코드: <span id="titleCustomerCode"></span>
						        						
						        		</li>
						        		<li>
						        			회사명: <span id="titleCustomerName"></span>
						        		</li>
						        		<li>
						        			사업자번호: <span id="titleCompanyRegNum"></span>
						        		</li>
						        		<li>
						        			가입일: <span id="titleSubscriptionDate"></span>
						        		</li>
						        		<li style="border:none;padding-right:0;">
						        			상태: <span id="titleOnSubscription"></span>
						        		</li>
						        		<li class="last" style="border-right:none;margin-right:0;"><a onClick="gotoM100()" class="button1 small-button">차량관제</a></li>
						        	</ul>
			        			</li>
			        			
			        		</ul>
	        			</div>
    			<div class="all-infomation" style="margin-top:15px;">
		        	<table  cellpadding="0" cellspacing="0">
		        		<tr class="company-info1">
		        			<th class="all-infomation-th">
		        				회사정보<br>
		        				<select style="width:75px;" id="customerType" name="customerType" onChange="updateCustomerType()">
								<option value="3">고객사</option>
								<option value="2">대리점</option>
								<option value="1">본사</option>
							</select>
		        			</th>
		        			<td >
		        				<div class="company-info1-content">
		        				<form id="companyInfoForm" name="companyInfoForm">
			        				<table  cellpadding="0" cellspacing="0" >
			        					<tr>
			        						<th style="width:50px;">회사명</th>
			        						<td style="width:135px;"><input type="text" name="customerName" id="customerName"></td>
			        						<th style="width:79px;">사업자번호</th>
			        						<td colspan="3" style="width:650px;"><input style="width:40px" type="text" id="companyRegNum1" maxlength="3">-<input style="width:30px"type="text" id="companyRegNum2" maxlength="2">-<input style="width:50px" type="text" id="companyRegNum3" maxlength="5">&nbsp;<a class="button1 small-button" onClick="getDupCheck()">중복검사</a>
			        						<input type="hidden" name="companyRegNum" id="companyRegNum"/>
			        						<a class="button1 small-button" style="margin-left:200px;" onClick="updateCompanyInfo()">변경저장</a>
			        						</td>
			        					
			        					</tr>
			        					<tr>
			        						<th>대표자</th>
			        						<td><input type="text" name="ceoName" id="ceoName"></td>
			        						<th>업태</th>
			        						<td style="width:120px"><input type="text" name="businessCondition" id="businessCondition"></td>
			        						<th style="width:80px;">종목</th>
			        						<td><input type="text" name="businessItem" id="businessItem"></td>
			        						
			        					</tr>
			        					<tr>
			        						<th>전화번호</th>
			        						<td><input type="text" id="handPhone" name="handPhone"></td>
			        						<th>전화번호2</th>
			        						<td><input type="text" id="handPhone2" name="handPhone2"></td>
			        						<th>이메일</th>
			        						<td><input type="text" id="email" name="email"></td>
			        					</tr>
			        					<tr>
			        						<th class="vlaigntop">주소</th>
			        						<td colspan="5">
			        							<input type="text" id="addressComponent3" name="addressComponent3"/>&nbsp;<a class="button1 small-button popup_open" rel="1">우편번호...</a><br>
			        							<input style="width:300px;" type="text" id="addressComponent1" name="addressComponent1" />
			        							<input style="width:315px;" type="text" id="addressComponent2" name="addressComponent2" />
			        							<input type="hidden" id="addressComponent4" name="addressComponent4"/>
			        						</td>
			        					</tr>
			        					<tr>
			        						<th>담당부서</th>
			        						<td><input type="text" id="dept" name="dept"></td>
			        						<th>담당자</th>
			        						<td><input type="text" id="officer" name="officer"></td>
			        						<th>연락처</th>
			        						<td><input type="text" id="phone" name="phone"></td>
			        					</tr>
			        					<tr>
			        						<th>결제일</th>
			        						<td>
			        							<select style="width:105px;" name="approvalDate">
			        								<option value="미지정">미지정</option>
			        								<c:forEach var="i" begin="1" end="31">
														<option value="${i}"><fmt:formatNumber value="${i}" pattern="00"/>일</option>
													</c:forEach>
			        								<option value='말일'>말일</option>
			        							</select>
			        						</td>
			        						<th>회계담당자</th>
			        						<td><input type="text" name="accountManager" id="accountManager"></td>
			        						<th style="width:120px;">세금계산서 이메일</th>
			        						<td><input type="text" name="email2" id="email2"></td>
			        					</tr>
			        					<tr>
			        						<th class="vlaigntop">비고</th>
			        						<td colspan="5">
			        							<textarea style="width:630px;height:70px;" id="description" name="description"></textarea>
			        						</td>
			        					</tr>
			        				</table>
			        				</form>
		        				</div>
		        			</td><!--company-info1-content-->
		        		</tr>
		        		<tr class="company-info1">
		        			<th class="all-infomation-th">
		        				가입정보
		        			</th>
		        			<td >
		        				<div class="company-info1-content">
		        					<form id="registInfo" name="registInfo">
			        				<table class="join-info" cellpadding="0" cellspacing="0" >
			        					<tr>
			        						<th>담당대리점: </th>
			        						<td><select style="width:127px;" name="agentCode" id="agentCode">
			        							<c:forEach var="vo" items="${mngCustomer}">
													<option value="${vo.customerCode}">${vo.customerName}</option>
			        							</c:forEach>
												</select>
											</td>
			        						<th>가입차량: </th>
			        						<td colspan="3" style="width:650px;"> <span id="regiCarCnt"></span>
			        						<a class="button1 small-button" style="margin-left:200px;" onClick="updateClosingDate()">해지처리</a>
			        						<a class="button1 small-button" onClick="updateRegistInfo()">변경저장</a>
			        						</td>
			        					
			        					</tr>
			        					<tr>
			        						<th>최초가입일: </th>
			        						<td><span id="subscriptionDate"></span></td>
			        						<th style="width:100px;">최초개통일: </th>
			        						<td><span id="openingDate"></span></td>
			        						<th>해지일: </th>
			        						<td><span id="closingDate"></span></td>
			        						
			        					</tr>
			        					<tr>
			        						<th>사용자관리기능사용: </th>
			        						<td style="width:150px;">
			        							<input type="radio" name="useUserManagement" id="useUserManagement" value="n" />미사용
			        							<input type="radio" name="useUserManagement" id="useUserManagement" value="y" />사용
			        						</td>
			        						<th>SMS사용: </th>
			        						<td style="width:120px;">
			        							<select name="serviceID" id="serviceID">
			        							<c:forEach var="vo" items="${service}">
													<option value="${vo.serviceID}">${vo.serviceName}</option>
			        							</c:forEach>
			        							</select>
			        						</td>
			        						<th style="width:100px;">SMS초과사용여부: </th>
			        						<td><input type="radio" name="useSMSOverLimit" id="useSMSOverLimit" value="n" />불허
			        							<input type="radio" name="useSMSOverLimit" id="useSMSOverLimit" value="y" />허용</td>
			        					</tr>
			        					<tr>
			        						<th style="width:100px;">차량제어  기능사용: </th>
			        						<td><input type="radio" name="privCarControl" id="privCarControl" value="n" />미사용
			        							<input type="radio" name="privCarControl" id="privCarControl" value="y"  />사용
			        						<th>데이터 유지기간: </th>
			        						<td colspan="3">
			        							<input type="radio" name="numOfMonthForData" id="numOfMonthForData" value="3"  />3개월
			        							<input type="radio" name="numOfMonthForData" id="numOfMonthForData" value="6"  />6개월
			        							<input type="radio" name="numOfMonthForData" id="numOfMonthForData" value="12" />1년
			        							<input type="radio" name="numOfMonthForData" id="numOfMonthForData" value="60" />5년
			        						</td>
			        					</tr>
			        					
			        				</table>
			        				</form>
		        				</div>
		        			</td><!-- second company-info1-content-->
		        		</tr>
		        		<tr>
		        			<th class="all-infomation-th"> 
		        				차량정보
		        			</th>
		        			<td>
		        				<div class="car-info-content">
		        					<div class="register">등록차량 : <span class="redLetter" id="totalCarCnt"></span> <a class="button1 add-button1 popup_open" rel="2">새 차량등록</a></div>
			        				<div class="m-541-table-wrapper">
				    					<div class="chart_head">
				    						<table cellpadding="0" cellspacing="0">
				    							<tr>
				    								<th width="30px">번호</th>
				    								<th width="90px">차량번호</th>
				    								<th width="80px">차량종류</th>
				    								<th width="90px">서비스종류</th>
				    								<th width="80px">등록일</th>
				    								<th width="80px">개통일</th>
				    								<th width="80px">해지일</th>
				    								<th width="80px">단말기모델</th>
				    								<th width="95px">단말기일렬번호</th>
				    								<th width="70px">단말기번호</th>
				    								<th width="*">관리</th>
				    								
				    							</tr>
				    						</table>
				    					</div>
				    					<div class="chart_body">
				    						<table cellpadding="0" cellspacing="0" id="carList">
				    							<tr style="cursor:pointer;">
				    								<td onClick="getCarDetailInfo(this)" width="30px" id="rownum">1</td>
					    							<td onClick="getCarDetailInfo(this)" width="90px" id="carRegiNumber">서울01가5555</td>
					    							<td onClick="getCarDetailInfo(this)" width="80px" id="typ_CarTypeName">버스</td>
					    							<td onClick="getCarDetailInfo(this)" width="90px" id="serviceName">DTG100</td>
					    							<td onClick="getCarDetailInfo(this)" width="80px" id="dev_RegiDate">2013-08-08</td>
					    							<td onClick="getCarDetailInfo(this)" width="80px" id="dev_DeliverDate">22013-08-08</td>
					    							<td onClick="getCarDetailInfo(this)" width="80px" id="dev_CancelDate"></td>
					    							<td onClick="getCarDetailInfo(this)" width="80px" id="dev_DeviceModel"></td>
					    							<td onClick="getCarDetailInfo(this)" width="95px" id="dev_DeviceSerial"></td>
					    							<td onClick="getCarDetailInfo(this)" width="70px" id="dev_DeviceID"></td>
					    							<td width="*" id="button3"><a onClick='getCarDeviceInfo(3, this)' class='button3 popup_open' rel='3'>단말교체</a><a class='button3' onClick="updateCarDeviceCancel(this)">해지</a></td>
					    							<td style="display:none;"><input type="text" name="carCode" id="carCode"/>
					    													  <input type="text" name="carDeviceCode" id="dev_CarDeviceCode"/>
					    							</td>
				    							</tr>
				    						</table>
				    					</div>
    								</div><!-- chart end-->
		        				</div>
		        			</td><!--.car-info-content end-->
		        		</tr>
		        		<tr>
		        			<th class="all-infomation-th">
		        				사용자정보
		        			</th>
		        			<td>
		        				<div class="usage-info-content">
		        					<form name="userForm" id="userForm">
		        					<table class="usage-table">
		        						<tr>
		        							<td colspan="4">
			        							<ul>
									        		<li style="border-right:1px solid gray;">
									        			계정 상태 : <span id="userFormLocked"></span>
									        						
									        		</li>
									        		<li>
									        			최종접속시각 : <span id="userFormLoginDate"></span>
									        		</li>
									        		<li style="margin-left:180px;">
									        			<input type="checkbox" name="locked" value="y"> 계정잠금
									        		</li>
									        		<li>
									        			<a class="button1 add-button1" onClick="updateUserInfo()">변경저장</a>
									        		</li>
									        		
									        	</ul>
			        						</td>
		        						</tr>
		        						<tr>
		        							<th style="padding:0;">담당자명</th>
			        						<td><input type="text" name="name" id="userFormName"></td>
			        						<th>아이디</th>
			        						<td>
			        							<input type="text" name="loginID" id="userFormLoginID"> 
			        							<a class="button1 small-button" onClick="getDupLoginID()">중복검사</a> &nbsp;<a class="button1 small-button popup_open" rel="4">비밀번호변경</a>
			        						</td>
			        					</tr>
		        						<tr>
		        							<th>전화번호</th>
			        						<td><input type="text" name="phone" id="userFormPhone"></td>
			        						<th>핸드폰</th>
			        						<td><input type="text" name="handPhone" id="userFormHandPhone"> </td>
			        						
		        						</tr>
		        						<tr>
		        							<th>일반 사용자</th>
		        							<td colspan="3"></td>
		        						</tr>
		        						<input type="hidden" name="userCode" id="userFormUserCode" />
		        						<input type="hidden" name="loginCheckYn" id="loginCheckYn" />
		        						<input type="hidden" name="loginPW" id="userFormLoginPW" />
		        					</table>
			        				<div class="m-541-table-wrapper">
							    		<div class="chart_head">
							    			<table cellpadding="0" cellspacing="0">
							    				<tr>
							    					<th width="50px">번호</th>
							    					<th width="90px">아이디</th>
							    					<th width="90px">이름</th>
							    					<th width="90px">소속</th>
							    					<th width="100px">전화번호</th>
							    					<th width="90px">SMS권한</th>
							    					<th width="100px">차량제어권한</th>
							    					<th width="100px">최종접속시각</th>
							    					<th width="*">계정상태</th>
							    				</tr>
							    			</table>
							    		</div>
							    		<div class="chart_body">
							    			<table cellpadding="0" cellspacing="0" id="userInfoList">
							    				<tr>
							    					<td width="50px" id="seq">1</td>
								    				<td width="90px" id="loginID">Hello</td>
								    				<td width="90px" id="name">이병철</td>
								    				<td width="90px" id="deptName">큐로테크</td>
								    				<td width="100px" id="phone">123-123-1234</td>
								    				<td width="90px" id="privSms">yes</td>
								    				<td width="100px" id="privCarControl">yes</td>
								    				<td width="100px" id="loginDate">2013-08-08</td>
								    				<td width="*" id="lockedName"></td>								    				
								    			</tr>								    									    			
							    			</table>
							    			</form>
							    		</div>
			    					</div><!-- chart end-->
		        				</div>
		        			</td><!--usage-info-content end-->
		        		</tr>
		        	</table>
	        	</div><!--all information end-->
				</div><!--table wrapper end-->
			</div>	<!--m541 end-->
		</div>	<!--mainContent end-->
		<div class="chart_footer">
		    <div class="footerCenter">
		       <span>Copyright ⓒ 2013 Qrotech Co.,Ltd. All rights reserved.</span>
		    </div>
	 	</div>	<!-- footer end-->	
	 	
	 	
	 	<div class="m330_popup_box" id="popup1">
		<div class="tableTitleA ">우편번호 검색<img class="popup_close" src="${imgUrl}/popup_close.png"></div>
		<div>
			<ul>
				<li>검색하실 주소의 동/읍/면을 입력하고 검색 버튼을 눌러 선택하세요.</li>
				
			</ul>
			<div class="searchZipcode">동/면/읍 검색 : <input type="text" name="searchName" id="postSearchName" onkeypress="if(event.keyCode==13) {getPostList(); return false;}"> <a class="button2">검색</a></div>
					<div class="tableLength">
						<div class="chart_head" >
							<table  valign="top" cellpadding="0" cellspacing="0"> 
								<tr valign="top" >
									<th width="70px">우편번호</th>
									<th width="*">주소</th>
								</tr>	
							</table>
						</div><!--chart_head end-->
						<div class="chart_body">
							<table cellpadding="0" cellspacing="0" id="zipCodeList"> 
								
							</table>
						</div>	
					</div>
			<div class="Rowbtn2"><a class="button2" onClick="setPostOK()">확인</a><a class="button2 last" onClick="popupClose()">취소</a></div>
		</div><!-- content end-->	
	</div>	<!--popup_box 330우편번호 검색-->
	
		<div class="blue-popup-box" id="popup2">
		<div class="tableTitleA ">차량등록<img class="popup_close" src="${imgUrl}/popup_close.png"></div>
			<div class="blue-popup-box-content">
			<form id="carInfoForm" name="carInfoForm" method="post">
				<table>
					<tr>
						<th>차량번호</th>
						<td class="padd"><input type="text" name="carRegiNumber" id="regCarRegiNumber"></td>
						<th class="blue-popup-box-th-width">차종</th>
						<td>
							<select class="blue-popup-box-select-width" name="carType" >
							<c:forEach var="vo" items="${carType}">
								<option value="${vo.carTypeCode}">${vo.carTypeName}</option>
							</c:forEach>
							</select>
						</td>
						
					</tr>
					<tr>
						<th>가입서비스</th>
						<td class="padd">
							<select style="width:127px;" name="regCarServiceID" id="regCarServiceID">
							<c:forEach var="vo" items="${DTGService}">
								<option value="${vo.serviceID}">${vo.serviceName}</option>
      						</c:forEach>
							</select>
						</td>
						<th class="blue-popup-box-th-width">가입일</th>
						<td><input type="text" class="datepicker" name="regiDate" id="carRegiDate"></td>
					</tr>
					<tr>
						<th>운전자명</th>
						<td class="padd"><input type="text" name="regiCarDriverName" id="regiCarDriverName"></td>
						<th class="blue-popup-box-th-width">운전자핸드폰</th>
						<td><input type="text" name="regiCarDriverPhone" id="regiCarDriverPhone"></td>
					</tr>
					<tr>
						<td colspan="4" class="redLetter">
							<hr>
							
						</td>
					</tr>
					<tr>
						<th>단말기모델</th>
						<td class="padd"><input type="text" name="deviceModel" id="deviceModel"></td>
						<th class="blue-popup-box-th-width">일렬번호</th>
						<td><input type="text" name="deviceSerial" id="deviceSerial"></td>
					</tr>
					
					<tr>
						<th>단말기번호</th>
						<td class="padd"><input type="text" name="deviceID" id="deviceID"></td>
						<th class="blue-popup-box-th-width">통신사</th>
						<td><select style="width:127px;" name="telecom">
								<option value="SKT">SKT</option>
								<option value="KT">KT</option>
								<option value="LGU">LG U+</option>
							</select></td>
					</tr>
					<tr>
						<th>출고일</th>
						<td><input class="datepicker" type="text" name="deliverDate" id="deviceDeliverDate"></td>
						<th class="blue-popup-box-th-width">개통일</th>
						<td><input class="datepicker" type="text" name="regiDate" id="deviceRegiDate"></td>
						
					</tr>
				
					<tr>
					<td colspan="4" class="redLetter">
						<hr>
						<input type="checkbox" id="dtgYn" value="y">디지털운행기록계
					</td>
					</tr>
				
					<tr>
						<th>DTG모델</th>
						<td class="padd"><input type="text" name="model" id="model"></td>
						<th class="blue-popup-box-th-width">일렬번호</th>
						<td><input type="text" name="serial" id="serial"></td>
					</tr>
					
					<tr>
						<th>출고일</th>
						<td><input class="datepicker" type="text" name="deliverDate" id="dtgDeliverDate"></td>
						<th class="blue-popup-box-th-width">장착일</th>
						<td><input class="datepicker" type="text" name="settingDate" id="dtgSettingDate"></td>
					</tr>
				</table>
			</form>
				<hr>
				<div class="redLetter">
					<input type="checkbox" id="etcDevice" value="y">기타 장치
				</div>
				<div>
					<input type="checkbox" id="themoSensor"><span>온도센서</span>
				</div>
				<hr>
				<div class="redLetter">
					• 날짜는 YYYYMMDD 형식으로 숫자로만 입력합니다.<br>
					• 전화번호는 ‘-’없이 숫자로만 입력합니다. <br>
				</div>
				<div class="button-center"> <a class="button2" onClick="regiCarInfo()">확인</a>&nbsp;&nbsp;<a class="button2" onClick="popupClose()">취소</a></div>
			</div>
		</div> <!--bleu-popup-box popup2-->
		
		<div class="blue-popup-box" id="popup5">
		<div class="tableTitleA ">차량등록<img class="popup_close" src="${imgUrl}/popup_close.png"></div>
			<div class="blue-popup-box-content">
			<form id="updateCarInfoForm" name="updateCarInfoForm" method="post">
			<input type="hidden" name="carCode" id="updateCarCode" />
				<table>
					<tr>
						<th>차량번호</th>
						<td class="padd"><input type="text" name="carRegiNumber" id="updateCarRegiNumber"></td>
						<th class="blue-popup-box-th-width">차종</th>
						<td>
							<select class="blue-popup-box-select-width" name="updateCarType" id="updateCarType">
							<c:forEach var="vo" items="${carType}">
								<option value="${vo.carTypeCode}">${vo.carTypeName}</option>
							</c:forEach>
							</select>
						</td>
						
					</tr>
					<tr>
						<th>가입서비스</th>
						<td class="padd">
							<select style="width:127px;" name="updateCarServiceID" id="updateCarServiceID">
							<c:forEach var="vo" items="${DTGService}">
								<option value="${vo.serviceID}">${vo.serviceName}</option>
      						</c:forEach>
							</select>
						</td>
						<th class="blue-popup-box-th-width">가입일</th>
						<td><input type="text" class="datepicker" name="regiDate" id="updateCarRegiDate"></td>
					</tr>
					<tr>
						<td colspan="4" class="redLetter">
							<hr>
							
						</td>
					</tr>
					<tr>
						<th>단말기모델</th>
						<td class="padd"><input type="text" name="deviceModel" id="updateDeviceModel"></td>
						<th class="blue-popup-box-th-width">일렬번호</th>
						<td><input type="text" name="deviceSerial" id="updateDeviceSerial"></td>
					</tr>
					
					<tr>
						<th>단말기번호</th>
						<td class="padd"><input type="text" name="deviceID" id="updateDeviceID"></td>
						<th class="blue-popup-box-th-width">통신사</th>
						<td><select style="width:127px;" name="updateTelecom" id="updateTelecom">
								<option value="SKT">SKT</option>
								<option value="KT">KT</option>
								<option value="LGU">LG U+</option>
							</select></td>
					</tr>
					<tr>
						<th>출고일</th>
						<td><input class="datepicker" type="text" name="deliverDate" id="updateDeviceDeliverDate"></td>
						<th class="blue-popup-box-th-width">개통일</th>
						<td><input class="datepicker" type="text" name="regiDate" id="updateDeviceRegiDate"></td>
						
					</tr>
				
					<tr>
					<td colspan="4" class="redLetter">
						<hr>
						<input type="checkbox" id="updateDtgYn" value="y">디지털운행기록계
					</td>
					</tr>
				
					<tr>
						<th>DTG모델</th>
						<td class="padd"><input type="text" name="model" id="updateModel"></td>
						<th class="blue-popup-box-th-width">일렬번호</th>
						<td><input type="text" name="serial" id="updateSerial"></td>
					</tr>
					
					<tr>
						<th>출고일</th>
						<td><input class="datepicker" type="text" name="deliverDate" id="updateDtgDeliverDate"></td>
						<th class="blue-popup-box-th-width">장착일</th>
						<td><input class="datepicker" type="text" name="settingDate" id="updateDtgSettingDate"></td>
					</tr>
				</table>
			</form>
				<hr>
				<div class="redLetter">
					<input type="checkbox" id="updateEtcDevice" value="y">기타 장치
				</div>
				<div>
					<input type="checkbox" id="updateThemoSensor"><span>온도센서</span>
				</div>
				<hr>
				<div class="redLetter">
					• 날짜는 YYYYMMDD 형식으로 숫자로만 입력합니다.<br>
					• 전화번호는 ‘-’없이 숫자로만 입력합니다. <br>
				</div>
				<div class="button-center"> <a class="button2" onClick="updateCarDetailInfo()">확인</a>&nbsp;&nbsp;<a class="button2" onClick="popupClose()">취소</a></div>
			</div>
		</div> <!--bleu-popup-box popup5-->
		
		<div class="blue-popup-box" id="popup3">
		<div class="tableTitleA "><span id="inputCarRegiNumber">서울01가5555</span>&nbsp;  단말기 교체정보<img class="popup_close" src="${imgUrl}/popup_close.png"></div>
			<div class="blue-popup-box-content">
			<form name="carDeviceForm" id="carDeviceForm">
				<table id="carDevice">
					<tr>
						<th>단말기모델</th>
						<td class="padd"><input name="deviceModel" id="inputDeviceModel" type="text"></td>
						<th>일렬번호</th>
						<td><input type="text" name="deviceSerial" id="inputDeviceSerial"></td>
					</tr>
					<tr>
						<th>단말기번호</th>
						<td class="padd"><input type="text" name="deviceID" id="inputDeviceID"></td>
						<th>통신사</th>
						<td><select style="width:127px;" name="inputTelecom" id="inputTelecom">
								<option value="SKT">SKT</option>
								<option value="KT">KT</option>
								<option value="LGU">LG U+</option>
							</select></td>
					</tr>
					<tr>
						<th>출고일</th>
						<td class="padd"><input class="datepicker" type="text" name="deliverDate" id="inputDeliverDate"></td>
						<th>개통일</th>
						<td><input class="datepicker" type="text" name="regiDate" id="inputRegiDate"></td>
					</tr>
					<input type="hidden" name="carDeviceCode" id="inputCarDeviceCode" />
					</form>
				</table>
				<div class="button-center"> <a class="button2" onClick="updateCarDeviceInfo()">확인</a>&nbsp;&nbsp;<a class="button2" onClick="popupClose()">취소</a></div>
			</div>
		</div> <!--bleu-popup-box popup3-->
		
		<div class="blue-popup-box" id="popup4">
			<div class="tableTitleA ">비밀번호 변경<img class="popup_close" src="${imgUrl}/popup_close.png"></div>
				<div class="blue-popup-box-content">
					<table>
						<tr>
							<th>비밀번호</th>
							<td><input type="password" id="popupLoginPW" name="popupLoginPW"></td>
						</tr>
						<tr>
							<th>비밀번호확인</th>
							<td><input type="password" id="popupLoginPW1" name="popupLoginPW1"></td>
						</tr>
					</table>
					<div class="button-center"> <a class="button2" onClick="updateLoginPW()">확인</a>&nbsp;&nbsp;<a class="button2" onClick="popupClose()">취소</a></div>
				</div>
		</div>
	<form id="theForm" name="theForm">
		<input type="hidden" name="customerCode" id="paramCustomerCode" value="${param.customerCode}">
	</form>
	<form name="postForm" id="postForm" style="display:none;">
		<input type="text" name="paramAddressComponent1" id="paramAddressComponent1">
		<input type="text" name="paramAddressComponent2" id="paramAddressComponent2">
		<input type="text" name="paramAddressComponent3" id="paramAddressComponent3">
		<input type="text" name="paramAddressComponent4" id="paramAddressComponent4">
		
	</form>
	<script language="javascript">
		var _this = this;
		$(document).ready(function(){			
			init();
			
			//디지털운행기록계 disable
			$("#model").attr("disabled", true);
			$("#serial").attr("disabled", true);
			$("#dtgDeliverDate").attr("disabled", true);
			$("#dtgSettingDate").attr("disabled", true);		
			//기타장치 disable
			$("#themoSensor").attr("disabled", true);
			
			$("#dtgYn").unbind('click');
			$("#dtgYn").bind('click', function(){
				if($("#dtgYn").is(':checked')){
					$("#model").attr("disabled", false);
					$("#serial").attr("disabled", false);
					$("#dtgDeliverDate").attr("disabled", false);
					$("#dtgSettingDate").attr("disabled", false);					
				} else {
					$("#model").attr("disabled", true);
					$("#serial").attr("disabled", true);
					$("#dtgDeliverDate").attr("disabled", true);
					$("#dtgSettingDate").attr("disabled", true);
				}
				
			});
			$("#etcDevice").unbind('click');
			$("#etcDevice").bind('click', function(){
				if($("#etcDevice").is(':checked')){
					$("#themoSensor").attr("disabled", false);
				} else {
					$("#themoSensor").attr("disabled", true);
				}
			});
		});
		function init() {
			getCompanyDetailInfo();
			getCarInfoList();
			getUserInfoList();
			getUserMngInfo();
		}
		function getCompanyDetailInfo() {
			var url='getCompanyDetailInfo.json';
			var param = "customerCode="+$("#paramCustomerCode").val();
			AjaxPost(url, param, function(data){
//	 	 		jsonLog(data.companyDetailInfo);
				//타이틀 회사정보
				$("#titleCustomerCode").text(data.companyDetailInfo['customerCode']);
				$("#titleCustomerName").text(data.companyDetailInfo['customerName']);
				$("#titleCompanyRegNum").text(data.companyDetailInfo['companyRegNum']);
				$("#titleSubscriptionDate").text(formatter.dateFormatYYYYMMDDHHMMSS(new Date(data.companyDetailInfo['subscriptionDate'])));
				if(data.companyDetailInfo['onSubscription'] == 'y') {
					$("#titleOnSubscription").text("정상");
				} else {
					$("#titleOnSubscription").text("해지");
				}
				
				//회사정보
				$("#customerName").val(data.companyDetailInfo['customerName']);
				
				var companyRegNum = data.companyDetailInfo['companyRegNum'];
				if(companyRegNum != null) {
					$("#companyRegNum1").val(companyRegNum.split("-")[0]);
					$("#companyRegNum2").val(companyRegNum.split("-")[1]);
					$("#companyRegNum3").val(companyRegNum.split("-")[2]);
				}
				
				$("#ceoName").val(data.companyDetailInfo['ceoName']);
				$("#businessCondition").val(data.companyDetailInfo['businessCondition']);
				$("#businessItem").val(data.companyDetailInfo['businessItem']);
				
				$("#phone").val(data.companyDetailInfo['phone']);
				$("#handPhone").val(data.companyDetailInfo['handPhone']);
				$("#handPhone2").val(data.companyDetailInfo['handPhone2']);
				$("#email").val(data.companyDetailInfo['email']);
				$("#addressComponent1").val(data.companyDetailInfo['addressComponent1']);
				$("#addressComponent2").val(data.companyDetailInfo['addressComponent2']);
				$("#addressComponent3").val(data.companyDetailInfo['addressComponent3']);
				$("#addressComponent4").val(data.companyDetailInfo['addressComponent4']);
				
				$("#dept").val(data.companyDetailInfo['dept']);
				$("#officer").val(data.companyDetailInfo['officer']);
				$("#phone").val(data.companyDetailInfo['phone']);
				
				if(data.companyDetailInfo['approvalDate'] != '') {
					$("#approvalDate option[value="+data.companyDetailInfo['approvalDate']+"]").prop("selected", true);
				} else {
					$('#approvalDate option[value="미지정"]').prop("selected", true);
				}
				$("#accountManager").val(data.companyDetailInfo['accountManager']);
				$("#email2").val(data.companyDetailInfo['email2']);
				
				$("#description").val(data.companyDetailInfo['description']);
				$("#customerType option[value="+data.companyDetailInfo['customerType']+"]").prop("selected", true);
				//가입정보
				if(data.companyDetailInfo['agentCode'] != null || data.companyDetailInfo['agentCode'] > 0) {
					$("#agentCode option[value="+data.companyDetailInfo['agentCode']+"]").prop("selected", true);
				} 
				
				$("#regiCarCnt").text(data.companyDetailInfo['regiCarCnt']+"대");
			 	var subscriptionDate = formatter.dateFormatYYYYMMDD(new Date(data.companyDetailInfo['subscriptionDate']));
				$("#subscriptionDate").text(subscriptionDate.split("-")[0]+"년 "+subscriptionDate.split("-")[1]+"월 "+subscriptionDate.split("-")[2]+"일");
			 	
			 	if(data.companyDetailInfo['openingDate'] != null && data.companyDetailInfo['openingDate'] != '') {
			 		var openingDate = formatter.dateFormatYYYYMMDD(new Date(data.companyDetailInfo['openingDate']));
					$("#openingDate").text(openingDate.split("-")[0]+"년 "+openingDate.split("-")[1]+"월 "+openingDate.split("-")[2]+"일");
			 	}
				
				if(data.companyDetailInfo['closingDate'] != null && data.companyDetailInfo['closingDate'] != '') {
			 		var closingDate = formatter.dateFormatYYYYMMDD(new Date(data.companyDetailInfo['closingDate']));
			 		$("#closingDate").text(closingDate.split("-")[0]+"년 "+closingDate.split("-")[1]+"월 "+closingDate.split("-")[2]+"일");
			 	}
				
				var useUserManagement = data.companyDetailInfo['useUserManagement'];
				if (useUserManagement != 'y') {
					useUserManagement = 'n';
				}
				var useSMSOverLimit = data.companyDetailInfo['useSMSOverLimit'];
				if (useSMSOverLimit != 'y') {
					useSMSOverLimit = 'n';
				}
				var privCarControl = data.companyDetailInfo['privCarControl'];
				if (privCarControl != 'y') {
					privCarControl = 'n';
				}
				var numOfMonthForData = data.companyDetailInfo['numOfMonthForData'];
				if (numOfMonthForData == null) {
					numOfMonthForData = 3;
				}
				
				$("input[name='useUserManagement']").filter('input[value='+useUserManagement+']').prop("checked", "checked");
				$("#serviceID option[value="+data.companyDetailInfo['serviceID']+"]").prop("selected", true);
				$("input[name='useSMSOverLimit']").filter('input[value='+useSMSOverLimit+']').prop("checked", "checked");
				$("input[name='privCarControl']").filter('input[value='+privCarControl+']').prop("checked", "checked");
				$("input[name='numOfMonthForData']").filter('input[value='+numOfMonthForData+']').prop("checked", "checked");
			});
		}
		//회사정보 사업자번호 중복검사
		function getDupCheck() {
			//type == 1 사업자번호
			try{
				var companyRegNum = $("#companyRegNum1").val()+"-"+$("#companyRegNum2").val()+"-"+$("#companyRegNum3").val();
	    		var url="getDupCheck.json";
	    		var param = "";	    		
	    		param = "companyRegNum="+companyRegNum+"&type=1";
	    		AjaxPost(url, param, function(data){
    				 if(data.cnt == 0) {
    					 alert('사용 가능합니다.');
    					 $("#companyRegNum").val(companyRegNum);
    				 } else {
    					 alert('이미 사용중입니다.');
    				 }
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		//회사정보 수정
		function updateCompanyInfo() {
			var companyRegNum = $("#companyRegNum1").val()+"-"+$("#companyRegNum2").val()+"-"+$("#companyRegNum3").val();
			$("#companyRegNum").val(companyRegNum);
			
			var url = "updateAdminCompanyInfo.json";
			var param = $("#companyInfoForm").serialize();
			param += "&customerCode="+$("#paramCustomerCode").val();
			
			try{	
	    		AjaxPost(url, param, function(data){
    				 alert(data.msg);
    				 getCompanyDetailInfo();
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		
		function updateCustomerType() {
			var customerType = $("select[name=customerType]").val();
			var customerCode = $("#paramCustomerCode").val();
			
			var url = "updateCustomerType.json";
			var param = {};
			param['customerType'] = customerType;
			param['customerCode'] = customerCode;
			
			try{	
	    		AjaxPost(url, param, function(data){
    				 alert(data.msg);
    				 init();
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		//가입정보 해지처리
		function updateClosingDate() {
			var customerCode = $("#paramCustomerCode").val();
			var url = "updateClosingDate.json";
			var param = "customerCode="+customerCode;
			
			try{	
	    		AjaxPost(url, param, function(data){
    				 alert(data.msg);
    				 getCompanyDetailInfo();
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		//가입정보 수정
		function updateRegistInfo() {
			var customerCode = $("#paramCustomerCode").val();
			var url = "updateAdminCompanyRegistInfo.json";
			var param = $("#registInfo").serialize()+"&customerCode="+customerCode;
			
			try{	
	    		AjaxPost(url, param, function(data){
    				 alert(data.msg);
    				 getCompanyDetailInfo();
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		//우편번호
		function getPostList() {
			try{
				var searchName = $("#postSearchName").val();
				if(searchName == "") {
					alert('검색어를 입력하세요.');
					return;
				}
				var rtnVal = "";
				var url = "getPostList.json";
				var param = "searchName="+searchName;
				AjaxPost(url, param, function(data){
	   			 jsonLog(data.postList);
		   			 if (data.postList.length > 0) {
		   				$(data.postList).each(function(ind) {
		   					rtnVal += "<tr valign='top' onClick='setAddress(this)' style='cursor:pointer;'>";
		   					rtnVal += "	<td width='70px' id='zipCode'>"+this['zipCode']+"</td>";
							rtnVal += " <td width='*' id='address'>"+this['sido']+" "+this['gugun']+" "+this['dong']+" "+this['bungi']+"</td>";
							rtnVal += " <td style='display:none;'><input type='hidden' id='bungi' value="+this['bungi']+">";
							rtnVal += " 						  <input type='hidden' id='sido' value="+this['sido']+">";
							rtnVal += " 						  <input type='hidden' id='gugun' value="+this['gugun']+"></td>";
							rtnVal += " <td id='dong' style='display:none;'>"+this['dong']+"</td>";
							rtnVal += "</tr>";
		   				});
		   				$("#zipCodeList").html(rtnVal);
		   			 }
				});
			}catch(e){
				
	    	}
		}
		function setAddress(tr) {
			$("#zipCodeList > tbody > tr > td").each(function() {
				$(this).css("background-color", "");
			});
			$(tr).find("#zipCode").css("background-color", "#FFFFCC");
			$(tr).find("#address").css("background-color", "#FFFFCC");
			
			var address = $(tr).find("#sido").val()+" "+$(tr).find("#gugun").val()+" "+$(tr).find("#dong").text();
			$("#paramAddressComponent1").val(address);
			$("#paramAddressComponent2").val($(tr).find("#bungi").val());
			$("#paramAddressComponent3").val($(tr).find("#zipCode").text());
			$("#paramAddressComponent4").val($(tr).find("#sido").val()); //sido
		}
		
		function setPostOK() {
			$("#addressComponent1").val($("#paramAddressComponent1").val());
			$("#addressComponent2").val($("#paramAddressComponent2").val());
			$("#addressComponent3").val($("#paramAddressComponent3").val());
			$("#addressComponent4").val($("#paramAddressComponent4").val());
			popupClose();
		}
		//회사정보, 가입정보 END
		//차량 정보 START
		function getCarInfoList() {
			_this.carList = tableSync('carList');
			var url="getCarInfoList.json";
			var param = "customerCode="+$("#paramCustomerCode").val();
			var carCnt = 0;
    		AjaxPost(url, param, function(data){
    			if (data.carInfoList.length > 0) {
    				$(data.carInfoList).each(function(ind) {
    					if(this['dev_RegiDate'] == null) {
    						this['dev_RegiDate'] = "-";
    					} else {
	    					this['dev_RegiDate'] = formatter.dateFormatYYYYMMDD(new Date(this['dev_RegiDate']));
    					}
    					
    					if(this['dev_DeliverDate'] == null) {
    						this['dev_DeliverDate'] = "-";	
    					} else {
    						this['dev_DeliverDate'] = formatter.dateFormatYYYYMMDD(new Date(this['dev_DeliverDate']));
    					}
    					
    					if(this['dev_CancelDate'] == null) {
    						this['dev_CancelDate'] = "-";
    						carCnt ++;
    					} else {
    						this['dev_CancelDate'] = formatter.dateFormatYYYYMMDD(new Date(this['dev_CancelDate']));
    					}
    				});
    				$("#totalCarCnt").text("총 "+carCnt+"대");
	    			_this.carList.tableAutoSync(data.carInfoList);
    			}
    			//getCarInfoListDetail();
    		});
		}
		function getCarInfoListDetail() {
			var closingDate = "";
			$("#carList > tbody > tr").each(function() {
				closingDate = $(this).find("#dev_CancelDate").text();
				if(closingDate == "-") {
					closingDate = "<a onClick=getCarDetailInfo(this) class='popup_open' rel='5'>-</a>";
					$(this).find("#dev_CancelDate").html(closingDate);
				}
			});
		}
		//차량 단말기 교체 정보
		function getCarDeviceInfo(popupNum, td) {			
			popupOpen(popupNum);
			$("#inputCarRegiNumber").text($(td).parent().parent().find("#carRegiNumber").text());
			var carDeviceCode = $(td).parent().parent().find("#dev_CarDeviceCode").val();
			var carCode = $(td).parent().parent().find("#carCode").val();
			var param = {};
			param['carDeviceCode'] = carDeviceCode;
			param['carCode'] = carCode;
			url = "getCarDeviceInfo.json";
			AjaxPost(url, param, function(data){
				$("#inputDeviceModel").val(data.carDeviceInfo['deviceModel']);
				$("#inputDeviceSerial").val(data.carDeviceInfo['deviceSerial']);
				$("#inputDeviceID").val(data.carDeviceInfo['deviceID']);
				$("#inputTelecom option[value="+data.carDeviceInfo['telecom']+"]").prop("selected", true);
				$("#inputDeliverDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDeviceInfo['deliverDate'])));
				$("#inputRegiDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDeviceInfo['regiDate'])));
				$("#inputCarDeviceCode").val(data.carDeviceInfo['carDeviceCode']);
			});
		}
		//차량 단말기 교체 정보 수정
		function updateCarDeviceInfo() {
			var param = {};
			param['deviceModel'] = $("#inputDeviceModel").val();
			param['deviceSerial'] = $("#inputDeviceSerial").val();
			param['deviceID'] = $("#inputDeviceID").val();
			param['telecom'] = $("select[name=inputTelecom]").val();
			param['deliverDate'] = formatter.getJavaFormatDate($("#inputDeliverDate").val());
			param['regiDate'] = formatter.getJavaFormatDate($("#inputRegiDate").val());
			param['carDeviceCode'] = $("#inputCarDeviceCode").val();
			var url = "updateCarDeviceInfo.json";
			AjaxPost(url, param, function(data) {
				alert(data.msg);
				popupClose();
				$('#carDeviceForm')[0].reset();
    			getCarInfoList();
			});
		}
		
		//차량 단말기 해지
		function updateCarDeviceCancel(td) {
			var carDeviceCode = $(td).parent().parent().find("#dev_CarDeviceCode").val();
			var carCode = $(td).parent().parent().find("#carCode").val();
			
			var param = {};
			param['carDeviceCode'] = carDeviceCode;
			param['carCode'] = carCode;
			
			var url = "updateCarDeviceCancel.json";
			AjaxPost(url, param, function(data) {
				alert(data.msg);
    			getCarInfoList();
			});
		}
		//새 차량등록
		function regiCarInfo() {
			var carParam = {};
			var carDeviceParam = {};
			var deviceParam = {};
			var carDriverParam = {};
			
			carParam['carRegiNumber'] = $("#regCarRegiNumber").val();
			carParam['customerCode'] = $("#paramCustomerCode").val();
			carParam['carType'] = $("select[name=carType]").val();
			carParam['serviceID'] =  $("select[name=regCarServiceID]").val();
			carParam['regiDate'] = formatter.getJavaFormatDate($("#carRegiDate").val());
			
			carDriverParam['name'] = $("#regiCarDriverName").val();
			carDriverParam['handPhone'] = $("#regiCarDriverPhone").val();
			carDriverParam['customerCode'] = $("#paramCustomerCode").val();
			
			carDeviceParam['deviceModel'] = $("#deviceModel").val();
			carDeviceParam['deviceSerial'] = $("#deviceSerial").val();
			carDeviceParam['deviceID'] = $("#deviceID").val();
			carDeviceParam['telecom'] = $("select[name=telecom]").val();
			carDeviceParam['deliverDate'] = formatter.getJavaFormatDate($("#deviceDeliverDate").val());
			carDeviceParam['regiDate'] = formatter.getJavaFormatDate($("#deviceRegiDate").val());
			
			deviceParam['model'] = $("#model").val();
			deviceParam['serial'] = $("#serial").val();
			deviceParam['deliverDate'] = formatter.getJavaFormatDate($("#dtgDeliverDate").val());
			deviceParam['settingDate'] = formatter.getJavaFormatDate($("#dtgSettingDate").val());
			
			try{
				//차량등록
	    		var url="regiCarInfo.json";
	    		AjaxPost(url, carParam, function(data){
	    			var carCode = "", carDriverCode = "";
	    			//등록된 차량 정보
	    			url = "getCarInfo.json";
	    			AjaxPost(url, carParam, function(data1){
	    				carCode = data1.carInfo['carCode'];
	    				carDriverCode = data1.carInfo['carDriverCode'];
	    				
	    				carDriverParam['carDriverCode'] = carDriverCode;
	    				
	    				//운전자 정보 등록
	 	    			url = "regiCarDriverInfo.json";
	 	    			AjaxPost(url, carDriverParam, function(data2){
	 	    			});
	 	    			
	    				carDeviceParam['carCode'] = carCode;
	 	    			deviceParam['carCode'] = carCode;
	 	    			//차량 단말기 정보 등록
	 	    			url = "regiCarDeviceInfo.json";
	 	    			AjaxPost(url, carDeviceParam, function(data2){
	 	    			});
	 	    			
	 	    			//DTG 정보 등록
 		    			url = "regiDTGDeviceInfo.json";
 		    			AjaxPost(url, deviceParam, function(data3){
 		    			});
	 	    			//기타장치 등록
		    			url = "regiThemoDeviceInfo.json";
		    			var param="carCode="+carCode;
		    			AjaxPost(url, param, function(data4){
		    				getCarInfoList();
		    			});
		    			alert(data.msg);
		    			popupClose();
		    			$('#carInfoForm')[0].reset();
		    		}); 	    			
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		
		//해지일 > 차량정보
		function getCarDetailInfo(td) {
			popupOpen(5);
			var carCode = $(td).parent().find("#carCode").val();
			$("#updateCarCode").val(carCode);
			
			var url = "getCarDetailInfo.json";
			var param = "carCode="+carCode;
 			AjaxPost(url, param, function(data){
 				$("#updateCarRegiNumber").val(data.carDetailInfo['carRegiNumber']);
 				$("#updateCarType option[value="+data.carDetailInfo['carType']+"]").prop("selected", true);
 				$("#updateCarServiceID option[value="+data.carDetailInfo['serviceID']+"]").prop("selected", true);
 				if (data.carDetailInfo['regiDate'] != null) {
	 				$("#updateCarRegiDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDetailInfo['regiDate'])));
 				}
 				
 				$("#updateDeviceModel").val(data.carDetailInfo['cdev_DeviceModel']);
 				$("#updateDeviceSerial").val(data.carDetailInfo['cdev_DeviceSerial']);
 				$("#updateDeviceID").val(data.carDetailInfo['cdev_DeviceID']);
 				$("#updateTelecom option[value="+data.carDetailInfo['cdev_Telecom']+"]").prop("selected", true);
 				if(data.carDetailInfo['cdev_DeliverDate'] != null) {
 					$("#updateDeviceDeliverDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDetailInfo['cdev_DeliverDate'])));
 				}
 				if(data.carDetailInfo['cdev_RegiDate'] != null) {
	 				$("#updateDeviceRegiDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDetailInfo['cdev_RegiDate'])));
 				}
 				
 				$("#updateDtgYn").unbind('click');
				$("#updateDtgYn").bind('click', function(){
					if($("#updateDtgYn").is(':checked')){
						$("#updateModel").attr("disabled", false);
						$("#updateSerial").attr("disabled", false);
						$("#updateDtgDeliverDate").attr("disabled", false);
						$("#updateDtgSettingDate").attr("disabled", false);					
					} else {
						$("#updateModel").attr("disabled", true);
						$("#updateSerial").attr("disabled", true);
						$("#updateDtgDeliverDate").attr("disabled", true);
						$("#updateDtgSettingDate").attr("disabled", true);
					}
					
				});
 				if(data.carDetailInfo['dtg_Model'] != null && data.carDetailInfo['dtg_Model'] != '') {
 					$("#updateDtgYn").prop("checked", "checked");
 					$("#updateModel").attr("disabled", false);
					$("#updateSerial").attr("disabled", false);
					$("#updateDtgDeliverDate").attr("disabled", false);
					$("#updateDtgSettingDate").attr("disabled", false);
 				} else {
 					$("#updateDtgYn").prop("checked", "");
 					
 					$("#updateModel").attr("disabled", true);
					$("#updateSerial").attr("disabled", true);
					$("#updateDtgDeliverDate").attr("disabled", true);
					$("#updateDtgSettingDate").attr("disabled", true);
 				}
 				
 				$("#updateModel").val(data.carDetailInfo['dtg_Model']);
 				$("#updateSerial").val(data.carDetailInfo['dtg_Serial']);
 				
 				if(data.carDetailInfo['dtg_DeliverDate'] != null) {
 					$("#updateDtgDeliverDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDetailInfo['dtg_DeliverDate'])));
 				}
 				
 				if(data.carDetailInfo['dtg_SettingDate'] != null) {
 					$("#updateDtgSettingDate").val(formatter.dateFormatYYYYMMDD(new Date(data.carDetailInfo['dtg_SettingDate'])));
 				}
				
 				$("#updateEtcDevice").unbind('click');
				$("#updateEtcDevice").bind('click', function(){
					if($("#updateEtcDevice").is(':checked')){
						$("#updateThemoSensor").attr("disabled", false);
					} else {
						$("#updateThemoSensor").attr("disabled", true);
					}
				});
				
 				if(data.carDetailInfo['themo_DeviceCode'] > 0) {
 					$("#updateEtcDevice").prop("checked", "checked");
 					$("#updateThemoSensor").prop("checked", "checked");
 					$("#updateThemoSensor").attr("disabled", false);
 				} else {
 					$("#updateEtcDevice").prop("checked", false);
 					$("#updateThemoSensor").prop("checked", false);
 					
 					$("#updateThemoSensor").attr("disabled", true);
 				}
 			});
		}
		//해지일 > 차량정보 > 확인
		function updateCarDetailInfo(){
			var param = {};
			param['carCode'] = $("#updateCarCode").val();
			param['carRegiNumber'] = $("#updateCarRegiNumber").val();			
			param['carType'] = $("select[name=updateCarType]").val();
			param['serviceID'] =  $("select[name=updateCarServiceID]").val();
			param['regiDate'] = formatter.getJavaFormatDate($("#updateCarRegiDate").val());

			param['cdev_DeviceModel'] = $("#updateDeviceModel").val();
			param['cdev_DeviceSerial'] = $("#updateDeviceSerial").val();
			param['cdev_DeviceID'] = $("#updateDeviceID").val();
			param['cdev_Telecom'] = $("select[name=updateTelecom]").val();
			param['cdev_DeliverDate'] = formatter.getJavaFormatDate($("#updateDeviceDeliverDate").val());
			param['cdev_RegiDate'] = formatter.getJavaFormatDate($("#updateDeviceRegiDate").val());
			
			param['dtg_Model'] = $("#updateModel").val();
			param['dtg_Serial'] = $("#updateSerial").val();
			param['dtg_DeliverDate'] = formatter.getJavaFormatDate($("#updateDtgDeliverDate").val());
			param['dtg_SettingDate'] = formatter.getJavaFormatDate($("#updateDtgSettingDate").val());
			
			if($("#updateThemoSensor").is(':checked')){
				param['themo_DeviceCode'] = 1;
			} else {
				param['themo_DeviceCode'] = 0;
			}
			
			var url = "updateCarDetailInfo.json";
 			AjaxPost(url, param, function(data){
 				alert(data.msg);
 				popupClose();
    			$('#updateCarInfoForm')[0].reset();
 				getCarInfoList();
 			});
		}
		//차량 정보 END
		//사용자 정보 START
		function getUserInfoList() {
			_this.userInfoList = tableSync('userInfoList');
			var url="getUserInfoList.json";
			var param = "customerCode="+$("#paramCustomerCode").val();
    		AjaxPost(url, param, function(data){
    			if (data.userInfoList.length > 0) {
    				$(data.userInfoList).each(function(ind) {
    					if(this['privSMS'] == 'y') {
    						this['privSms'] = "yes";
    					} else {
    						this['privSms'] = "no";
    					}
    					if(this['privCarControl'] == 'y') {
    						this['privCarControl'] = "yes";
    					} else {
    						this['privCarControl'] = "no";
    					}
    					
    					if(this['locked'] == 'y') {
    						this['lockedName'] = "잠김"; 
    					} else {
    						this['lockedName'] = "";
    					}
    					
    					if(this['loginDate']  != null) {
    						this['loginDate'] = formatter.dateFormatYYYYMMDD(new Date(this['loginDate']));
    					} else {
    						this['loginDate'] = "";  						
    					}
    				});
	    			_this.userInfoList.tableAutoSync(data.userInfoList);
    			}
    			
    			if(data.userAdminInfo != null) {
    				var locked = data.userAdminInfo['locked'];
    				if(locked == 'y') {
    					$("#userFormLocked").text("잠김");
    					$("input[name='locked']").prop("checked", "checked");
    				} else {
    					$("#userFormLocked").text("정상");
    					$("input[name='locked']").prop("checked", "");
    				}
    			}
    		});
		}
		
		function getUserMngInfo() {
			var url="getUserMngInfo.json";
			var param = "customerCode="+$("#paramCustomerCode").val();
    		AjaxPost(url, param, function(data){
    			if(data.userMngInfo != null) {
	    			var locked = data.userMngInfo['locked'];
	    			if(locked == 'y') {
	    				$("#userFormLocked").text("차단");
	    				$("input[name='locked']").prop("checked", "checked");
	    			} else {
	    				$("#userFormLocked").text("정상");
	    				$("input[name='locked']").prop("checked", "");
	    			}
	    			if (data.userMngInfo['loginDate'] != null) {
	    				$("#userFormLoginDate").text(formatter.dateFormatYYYYMMDDHHMMSS2(new Date(data.userMngInfo['loginDate'])));
	    			}
	    			
	    			$("#userFormName").val(data.userMngInfo['name']);
	    			$("#userFormLoginID").val(data.userMngInfo['loginID']);
	    			$("#userFormPhone").val(data.userMngInfo['phone']);
	    			$("#userFormHandPhone").val(data.userMngInfo['handPhone']);
	    			$("#userFormUserCode").val(data.userMngInfo['userCode']);
	    			$("#popupLoginPW").val(data.userMngInfo['loginPW']);
	    			$("#popupLoginPW1").val(data.userMngInfo['loginPW']);
	    			$("#userFormLoginPW").val(data.userMngInfo['loginPW']);
    			}
    		});
		}
		function getDupLoginID() {
			if($("#userFormLoginID").val() == '') {
				alert("아이디를 입력하세요.");
				return;
			}
			var url="getDupLoginID.json";			
			var param = "userCode="+$("#userFormUserCode").val()+"&loginID="+$("#userFormLoginID").val();
			
    		AjaxPost(url, param, function(data){
    			if(data.cnt > 0) {
    				alert('중복된 아이디입니다.');
    				$("#loginCheckYn").val("y");
    				
    			} else {
    				alert('사용 가능한 아이디입니다.');
    				$("#loginCheckYn").val("n");
    			}
    		});
		}
		function updateLoginPW(){
			var userCode = $('#userFormUserCode').val();
			
			if(userCode == '') {
				alert('사용자를 선택하세요.');
				return;
			}
			
			if ($('#popupLoginPW').val() != $('#popupLoginPW1').val()) {
				alert('비밀번호가 맞지 않습니다.');
				$('#popupLoginPW1').focus();
				return;
			}
			$('#userFormLoginPW').val($('#popupLoginPW').val());
			popupClose();
		}
		
		function updateUserInfo() {
			var userCode = $("#userFormUserCode").val();
			if(userCode == '') {
				alert('사용자를 선택하세요.');
				return;
			}
			if($("#loginCheckYn").val() == '') {
				alert('아이디 중복체크를 하세요.');
				return;
			}
			else if($("#loginCheckYn").val() == 'y'){
				alert('아이디를 확인하세요.');
				return;
			}
			
			if($('#userFormLoginPW').val() == '') {				
				 alert('비밀번호를 확인해주세요.');
				 return;
			}
			var param = $("#userForm").serialize();
			if(!$("input[name=locked]").is(":checked")) {
				param += "&locked=n";			
			}
			
			try{
	    		var url="updateUserListDetail.json";
	    		AjaxPost(url, param, function(data){
    				 alert(data.msg);
    				 getUserInfoList();
	    		});
	    	}catch(e){
	    		//logs(e);
	    	}
		}
		//사용자 정보 END
		function popupOpen(num) {
			$('#overlay').css('display', 'block');
			var cl = $('#popup' + num).attr('class');
			var height = parseInt($('#popup' + num).height());
	        
	        var width = parseInt($('#popup' + num).width());
	        
	        $('.' + cl).css("top", (($(window).innerHeight() / 2)-(height / 2)) + 'px');
	       	$('.' + cl).css("left", (($(window).innerWidth() / 2) - (width / 2)) + 'px');
	        
	        $('#popup' + num).show();
		}
		
		function popupClose(num) {
			$('#overlay').css('display', 'none');
			if(num == null) {
		        for(var index = 1; index <= 5; index++){
		        	$('#popup' + index).hide();
		       }
			} else {
				$('#popup' + num).hide();
			}
		}
		
		function gotoM100() {
			$("#theForm").attr("action", "/totalCarListMain");
			$("#theForm").submit();
		}
		
		function getSearchName(searchName){			
   	    	$('#searchName').autocomplete({
   	    		delay:500,
                source:function(request, response){
                	var url="getCompanyDetailSearchName.json";
        			
            	    var searchType = $("#searchType option:selected").val();    	    
            	    var param={};
            	    param['searchType'] = searchType;
        			param['searchName'] = searchName;
        			
                	AjaxPost(url, param, function(data){
                		response( $.map( data.searchName, function( item ) {
                			var name="";
	                		if(searchType == 1) {
	                			name = item.customerName;
	                		} else if(searchType == 3){
	                			name = item.companyRegNum;
	                		} 
	                		
	                		if(searchType == 2) {
	                			name = item.customerCode;
	                			return {
                                  label: name,
                                  value: name
                                }
	                		}
                            if (name.toLowerCase().indexOf($("#searchName").val().toLowerCase()) >= 0)
                            {
                            	return {
                                  label: name.toLowerCase().replace($("#searchName").val().toLowerCase(),$("#searchName").val().toLowerCase()),
                                  value: name
                                }
                            }
                      	}));
                	});
                },
                select: function (event, ui) {
                    //아이템 선택시 처리 코드
                	getSearch();
                },	                
                selectFirst: true,
                minLength: 1,
                open: function () {
                   // $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
                    $('.ui-autocomplete.ui-menu').css('width', '150px');
                },
                close: function () {
                    //$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
                }
   	        });
		}
		
		function getSearch() {
			
			var url="getSearch.json";
			
    	    var searchType = $("#searchType option:selected").val();
    	    var searchName = $("#searchName").val();
    	    
    	    if(searchName == "") {
    	    	return;
    	    }
    	    var param={};
    	    param['searchType'] = searchType;
			param['searchName'] = searchName;
			
        	AjaxPost(url, param, function(data){
        		$("#paramCustomerCode").val(data.customerInfo['customerCode']);
        		init();
        	});
		} 
	</script>
  </body>
</html>
